<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>登入 - layuiAdmin</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <script src="../../layuilay/layui.js" charset="utf-8"></script>
  <script src="../../js/jquery-3.4.1.min.js" charset="utf-8"></script>
  <link rel="stylesheet" href="../../layuilay/css/layui.css"  media="all">
  
  <link rel="stylesheet" href="../../layui/src/layuiadmin/style/admin.css" media="all">
  <link rel="stylesheet" href="../../layui/src/layuiadmin/style/login.css" media="all">
</head>
<style>
            select{
                font-family: "微软雅黑";
                margin:60px;
                background: rgba(0, 150, 136);
                width: 249px;
                height: 40px;
                font-size: 18px;
                color: white;
                text-align: center;
                border: 1px #1a1a1a solid;
                border-radius: 5px;
            }
            option{
                color: black;
                background: #A6E1EC;
                line-height: 20px;
            }
            select:focus{
                border: 2px #ddd solid;
                box-shadow: 0 0 15px 1px #DDDDDD;
            }
            option:hover{
                background: #EBCCD1;
            }
</style>
<script>
layui.use(['jquery','layer'], function(){
	 var $ = layui.$;
	 var layer = layui.layer;
	 
  $(function(){
      $("#log").click(function(){
          var r_id = $("#LAY-user-login-username").val();
          var password = $("#LAY-user-login-password").val();
          var staus = $("#LAY-user-login-staus").val();
          if ("" == r_id){
              layer.msg("请输入账号！");
              flag = false;
              return false;
          }else if ("" == password){
        	  layer.msg("请输入密码！");
              flag = false;
              return false;
          }else if ("" == staus){
              layer.msg("请选择身份！");
              flag = false;
              return false;
          }
          if(flag == true){
              return true;
          }
         var flag= $.ajax({
              url:"../../findByR_idAndpassword",
              data:{
                  r_id:r_id,
                  staus:staus,
                  password:password
              },
              dataType:"json",
              type:"post",
              success:function(res){
                  if(res.success){
                	  window.localStorage.setItem("loginid",res.object.r_id);
                      window.localStorage.setItem("loginname",res.object.name);
                      window.localStorage.setItem("loginpassword",res.object.password);
                      window.localStorage.setItem("loginsex",res.object.sex);
                	  layer.msg("登陆成功");
                	  if(staus == 3 || staus == 4){
                		  window.location.href="../index.html";
                	  }else if(staus ==1 || staus == 2){
                		  window.location.href="../stindex.html";
                	  }
                     
                  }else{
                	  layer.msg("账号或密码输入错误");
                  }
              }
          })
      })
  })
  })
</script>
<body>
  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>暗礁图书管理平台</h2>
      </div>
      <select id="LAY-user-login-staus">
            <option value="">请您的选择身份</option>
                          <option value="1">老师</option>
                          <option value="2">学生</option>
                          <option value="3">管理员</option>
                          <option value="4">馆长</option>
        </select>
      <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
          
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
          <input type="text" id="LAY-user-login-username" lay-verify="required" placeholder="用户ID" class="layui-input">
        </div>
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
          <input type="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
        </div>

        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit" id="log">登 入</button>
        </div>
      </div>
    </div>
    
    <div class="layui-trans layadmin-user-login-footer">
      
    </div>
  </div>

 
</body>
</html>